Showing posts with label Volume 118. Show all posts
Showing posts with label Volume 118. Show all posts

SOlution of 11877 - The Coco-Cola Store

Problem Description
source:https://uva.onlinejudge.org/external/118/11877.html

Once upon a time, there is a special coco-cola store. If you return three empty bottles to the shop, you’ll get a full bottle of coco-cola to drink. If you have n empty bottles right in your hand, how many full bottles of coco-cola can you drink? 

Input 

There will be at most 10 test cases, each containing a single line with an integer n (1 ≤ n ≤ 100). The input terminates with n = 0, which should not be processed. 

image

Solution of 11876 - N + NOD (N)

Problem Description
source:https://uva.onlinejudge.org/external/118/11876.uva

Consider an integer sequence N where, 

N0 = 1 
Ni = Ni−1 + NOD(Ni−1) for i > 0 
        Here, NOD(x) = number of divisors of x. 
        So the first few terms of this sequence are 1 2 4 7 9 12 18 ... 

Given two integers A and B, find out the number of integers in the above sequence that lies within the range [A, B]. 

Solution of 11875 - Brick Game

Problem Description
source:https://uva.onlinejudge.org/external/118/11875.html

There is a village in Bangladesh, where brick game is very popular. Brick game is a team game. Each team consists of odd number of players. Number of players must be greater than 1 but cannot be greater than 10. Age of each player must be within 11 and 20. No two players can have the same age. There is a captain for each team. The communication gap between two players depends on their age difference, i.e. the communication gap is larger if the age difference is larger. Hence they select the captain of a team in such a way so that the number of players in the team who are younger than that captain is equal to the number of players who are older than that captain. Ages of all members of the team are provided. You have to determine the age of the captain.

image

Solution of 11805 - Bafana Bafana

Problem Description
source:https://uva.onlinejudge.org/external/118/11805.html

Team practice is very important not only for programming contest but also for football. By team practice players can learn cooperating with team mates. For playing as a team improvement of passing skill is very important. Passing is a great way of getting the ball upfield and reduces the risk of giving the ball away.
   Carlos Alberto Parreira, the coach of Bafana Bafana, also wants his players to practice passing a lot. That’s why, while in the training camp for soccer world cup 2010, every day he asks all of the players who are present in practice to stand in a circle and practice passing. If N players are in practice, he gives each of the players a distinct number from 1 to N, and asks them to stand sequentially, so that player 2 will stand in right side of player 1 and player 3 will stand in right side of player 2, and so on. As they are in a circle, player 1 will stand right to player N.
   The rule of passing practice is, Parreira will give the ball to player K, and practice will start. Practice will come to an end after P passes. In each pass, a player will give the ball to his partner who is in his immediate right side. After P passes, the player who owns the ball at that moment will give the ball back to Parreira.
    Parreira wants to be ensured that his players practice according the rule. So he wants a program which will tell him which player will give him the ball back. So after taking the ball from the same person he can be happy that, the players play according to the rules. Otherwise he will ask them to start from beginning.

image